using Assets.Scripts.GDK;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

namespace Brick
{
	public class LevelPanel : gdk_base_UI
	{
		public RectTransform scrollContent;

		public RectTransform rowItemBox;

		public Scrollbar sbar;

		public Text zuanshiText;

		public Text starsText;

		public override void OnStart()
		{
			starsText.text = GameData.stars + string.Empty;
			zuanshiText.text = GameData.coin + string.Empty;
			initData();
		}

		public void initData()
		{
			rowItemBox.gameObject.SetActive(value: true);
			gdk_utils.removeAllChildren(scrollContent);
			int num = 150;
			int index = GameData.index;
			for (int i = 1; i <= num; i++)
			{
				RectTransform rectTransform = Object.Instantiate(rowItemBox);
				rectTransform.gameObject.SetActive(value: true);
				rectTransform.SetParent(scrollContent, worldPositionStays: false);
				rectTransform.GetComponent<LevelItem>().OnData(i);
			}
			rowItemBox.gameObject.SetActive(value: false);
			OnSkipToCur();
		}

		private void OnSkipToCur()
		{
			if (GameData.index >= 20)
			{
				int num = 37;
				int num2 = (150 - GameData.index) / 4;
				float pLine = (float)num2 * 1f / (float)num;
				DOTween.To(delegate
				{
					float num3 = pLine;
					sbar.value = num3;
					return num3;
				}, delegate (float v)
				{
					sbar.value = v;
				}, pLine, 0.1f).SetEase(Ease.InElastic);
			}
		}

		public void OnBackLobbyClick()
		{
			gdk_game_manager.PlaySound(AudioID.click);
			gdk_game_manager.blackScene();		
		}

		public void OnShopClick()
		{
			GDK.ModuleManger.Module<ShopPanelModule>().SetPage(0);
			gdk_game_manager.PlaySound(AudioID.click);
			gdk_game_manager.showPanel(PanelID.SHOP);			
		}

		public void OnAchieveClick()
		{
			gdk_game_manager.PlaySound(AudioID.click);
			gdk_game_manager.showPanel(PanelID.ACHIEVE);
		}

		public void OnPackageClick()
		{
			GDK.ModuleManger.Module<ShopPanelModule>().SetPage(1);
			gdk_game_manager.PlaySound(AudioID.click);
			gdk_game_manager.showPanel(PanelID.DIAMONDSHOP);
		}
	}
}

